package com.wise.site.protocol.result;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.wise.site.protocol.base.SoapItem;
import com.wise.site.protocol.base.SoapResult;

/**
 * 列表数据容器
 * @author huangyue
 *
 */
public class InfoItemsResult extends SoapResult {
	public List<SoapItem> list;
	
	@Override
	public void parseData(String response) throws Exception {
		JSONObject json = new JSONObject(response);
		if(json.getInt("flag") == 1){
			JSONArray array = new JSONArray(json.getString("msg"));
			list = new ArrayList<SoapItem> ();
			InfoItem item = null;
			for(int i = 0; i < array.length(); i++){
				item = new InfoItem(array.getJSONObject(i));
				list.add(item);
			}
		}
//		test() ;
	}
	
	private void test() {
		list = new ArrayList<SoapItem> ();
		InfoItem item = new InfoItem();
		item.iconURL = "test/test_list.jpg";
		item.tilte = "sdasfgawr";
		item.snipe = "test/fda.jpg";
		item.date = "23214335412";
		list.add(item);
		item = new InfoItem();
		item.iconURL = "test/test_list.jpg";
		item.tilte = "erq";
		item.snipe = "test/fa.jpg";
		item.date = "23214335412";
		list.add(item);
		item = new InfoItem();
		item.iconURL = "test/test_list.jpg";
		item.tilte = "hrty";
		item.snipe = "test/sggsrgq.jpg";
		item.date = "fad13343";
		list.add(item);
	}

}
